home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 44 / Amiga Format CD44 (1999-08-26)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-10].iso / -in_the_mag- / basics / amos / checksum.lha / checksum.asc next >
Text File  |  1996-09-01  |  632b  |  37 lines

  1. Rem By Patrik Jansson 1/9 1996 FreeWare
  2.  
  3. Rem Out going mess 
  4. Print "Enter an EAN13-cods first 12 digits:"
  5.  
  6. Rem We need two... 
  7. Dim SUM(2)
  8.  
  9. Rem  Input 12 numbers  
  10. Do 
  11.    Input NUM$
  12.  
  13.    Rem 12?
  14.    Exit If Len(NUM$)=12
  15.  
  16.    Rem Sorry... 
  17.    Print "ERROR!"
  18.  
  19. Loop 
  20.  
  21. Rem lets add those odd and even numbers together!
  22. Do 
  23.    For E=1 To 2
  24.       Inc D
  25.       Add SUM(E),Val(Mid$(NUM$,D,1))
  26.       If D=>Len(NUM$) Then Exit 2
  27.    Next 
  28. Loop 
  29.  
  30. Rem the secret is even*3+odd and what ever remains to the next 10 is the 
  31. Rem checksum 
  32. CHSUM=SUM(1)+SUM(2)*3
  33. CHSUM=10-Val(Right$(Str$(CHSUM),1))
  34.  
  35. Rem reveal the secret
  36. Print "Checksum digit is:";CHSUM
  37.